class HttpRequest(object):
    # 请求解析类
    GET = None
    body = None
    POST = None
    path = None

    def pare(self, data):
        # 解析数据
        data_split = data.split(' ')
        self.path = data_split[1]
        try:
            data = self.path.split('?')
            self.GET = data[1]
            self.path = data[0]
        except:
            pass


class HttpResponse():
    """
        返回字符串
    """

    def __init__(self, data=None, status=200):
        response = 'HTTP/1.1 %d ok\r\nContent-Type:text/html;charset=utf-8\r\nServer:Ming1.1\r\n\r\n' % status + data

        self.response_data = response.encode()

import json
class JsonResponse():
    """
        返回json数据
    """
    def __init__(self, data=None, status=200):
        """

        :param data: 返回的数据 接受的是字典
        :param status:
        """
        response = 'HTTP/1.1 %d ok\r\nContent-Type:application/json;charset=utf-8\r\nAccess-Control-Allow-Origin:http://0.0.0.0:8080\r\nServer:Ming1.1\r\n\r\n' % status + json.dumps(data)

        self.response_data = response.encode()

